home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / NEWSOFT / AUGUST / MESSENGER / !Messenger / Resources / !OLEedit / !Help < prev    next >
Text File  |  1994-07-19  |  11KB  |  263 lines

  1. Help file for OLE Edit
  2. ~~~~~~~~~~~~~~~~~~~~~~
  3.  
  4. OLE Edit is an OLE server capable of editing text files for other
  5. applications.
  6.  
  7. In use, when a file is sent to it, OLE Edit opens up a window allowing
  8. editing operations. Other than available memory there is no practical limit
  9. on the number of sessions OLE Edit can handle. The file is sent back to the
  10. client when OK is clicked, and as normal, clicking with Adjust retains the
  11. window on screen. Even if it is closed, however, the file is still retained
  12. by OLE Edit in order that future edit requests by the client (format 2 on
  13. Message_OLEOpenSession) can be dealt with much faster.
  14.  
  15. OLE Edit will discard a file only when Cancel is clicked, or when told to by
  16. its client or when quit from the Task Manager. When quit it will inform all
  17. clients that their sessions are being closed. When OLE Edit is told to close
  18. its one remaining session, it will quit automatically. Therefore if a client
  19. sends a close-all-sessions when it is quit, and OLE Edit has no sessions with
  20. another client, OLE will quit along with its client.
  21.  
  22. There is no iconbar icon, as this application only exists to serve others and
  23. is not useful in its own right.
  24.  
  25. OLE Edit version 2.00 is a much more powerful editor than OLEdit was. It has
  26. been completely re-written using RiscOSLib, which makes certain other things
  27. a right royal pain (pane handling is flaky, for instance, and proper
  28. titlebar/close-icon control is near-impossible) but which does have a full
  29. text editor. So now OLE Edit gives you something extremely similar to !Edit.
  30. As such it need not really be considered a mere 'stop-gap' any more as it is
  31. now a powerful and fully-featured text editor and (while improvements may be
  32. forthcoming from this quarter) will now suffice until !Edit in a future RISC
  33. OS is OLE compliant. In other words, probably forever! Being programmed using
  34. RiscOSLib, it *may* be compatible with RISC OS 2, but I have no way of
  35. testing this.
  36.  
  37. OLE Edit may be distributed freely with freeware and commercial applications
  38. which need to OLE text files, so such applications can rest secure in the
  39. knowledge that there is an OLE text server available on its run-time system.
  40.  
  41. Behaviour
  42. ~~~~~~~~~
  43.  
  44. OLE Edit conforms to Computer Concepts' OLE protocol as defined in the file
  45. OLESpec, included here. Note that there is an error in this file (apart from
  46. the typos) under Message_OLECloseSession, where the paragraph under the
  47. message block description *should* read:
  48.  
  49.   Note, the server can send this message to a client or broadcast it to
  50.   all clients when sessions are being closed from the server's end. (ie
  51.   the user is closing the application down or removing one of its
  52.   documents).
  53.  
  54. The original said that 'the *client* can send this message to a client or
  55. broadcast it to all clients when sessions are being closed from the clients
  56. end.', which was nonsensical and confused me for a while as it seemed there
  57. was no way for a server to tell a client when it's dying. Well, there is. The
  58. server can send the Message_OLECloseSession as well as receive it. In fact
  59. the notes in OLESpec regarding Message_OLECloseSession are still ambiguous on
  60. what should happen when you send -1 as a session number. I've tried to be
  61. intelligent, so that if OLE Edit receives such a message from a client it
  62. only closes down the sessions belonging to the task which sent it, not all of
  63. them (of course, that may *be* all of them, in which case OLE Edit will quit
  64. itself). Conversely, it seems that clients receiving such a message from a
  65. server should only close down editing sessions it has with that server. This
  66. then ensures that certain servers or clients dying don't interfere with other
  67. servers and clients which probably use different filetypes and are an
  68. unrelated operation.
  69.  
  70. The !Boot file is set up so that OLE Edit will only announce itself as an OLE
  71. server for text files if there is not one already present.
  72.  
  73. Further ruminations on OLE
  74. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  75.  
  76. I note the comments made on Arcade re: the thought that OLE is something of a
  77. misnomer for what this, and the CC OLE Protocol provide, which is not in the
  78. same league as OLE as found on other platforms.
  79.  
  80. Here's a hint when writing a server that may want to use this: Assuming your
  81. file is not too big, why not send it via PipeFS rather than Wimp$Scrap? Even
  82. the old OLEdit 1.00 could cope with this as it's invisible from the server's
  83. end. This means that the file is transferred via RAM instead of disk, thus
  84. making it *much* faster, and far more convenient for floppy-users. When you
  85. send your file, save it to "Pipe:$.<leafname>". According to the protocol,
  86. the server *can* send back a different pathname with the OLEFileChanged
  87. message in case it decided that the file grew big enough for PipeFS not to be
  88. appropriate, and so the client should take note of this and not blindly
  89. assume it was put back where it came from. At present, however, OLE Edit will
  90. not change the pathname; it will *always* put the file back where it came
  91. from, regardless of how much it may have grown and where it might have been
  92. Saved in the meantime.
  93.  
  94. There is one fly in this ointment however, in that CC's OLE Support module
  95. does not like PipeFS. It sends the file all right, but won't send back the
  96. OLEFileChanged message when the file is saved back. Presumably this is
  97. because the file-watching facility stops when the file disappears from
  98. Pipe:$, which it does as soon as the server reads it in. That's the way
  99. PipeFS seems to work. So if you determine that the OLE server for your new
  100. session is in fact OLE Support (scan the OLEServer$Type system variable), go
  101. via Wimp$Scrap or some other 'real' filing system.
  102.  
  103. OLE Edit now only responds to requests to edit Text files. Beforehand it would intercept anything, once it was running, regardless of type. However, of course, a text editor might be wanted to edit files which are not Textfiles, eg Obey files, Desktop files, bare data files. Therefore my interpretation of how this is dealt with is as follows:
  104.  
  105. When you send the OLEOpenSession (formats 0 & 1), send in the filetype field
  106. the type you want the file edited as. eg: an Obey file needs to be edited as
  107. a text file. However, when you do your file save, set the filetype on the
  108. saved file to the proper type (ie: Obey) OLE Edit will then edit the file as
  109. a text file, ignoring files sent with a different type, but will still show
  110. (in file info, save etc) that it is whatever type it was saved with.
  111.  
  112. Copyright
  113. ~~~~~~~~~
  114.  
  115. This program is © Peter Greenham & Ting Kuei 1994. FREEWARE. The conditions
  116. are as follows:
  117.  
  118. 1: You may distribute it freely either on its own or with PUBLIC DOMAIN,
  119.    FREEWARE or CAREWARE applications, under normal Freeware conditions. ie:
  120.    that no charge is made beyond that necessary to cover costs.
  121.  
  122. 2: You may distribute it as part of a COMMERCIAL or SHAREWARE application
  123.    PROVIDED:
  124.  
  125.    a: it is only a PART of the entire package
  126.    b: the primary application requires an OLE server for text files and the
  127.       vendor does not have a license to distribute the OLE Support module.
  128.  
  129. 3: It must be distributed complete and unaltered, including this file.
  130.  
  131. 4: So long as the above conditions are met, you may if you wish distribute
  132.    !OLEedit inside your client application's directory so as to make it
  133.    invisible to the end-user.
  134.  
  135. 5: Copyright remains with us, and we reserve the right to change the terms of
  136.    distribution for future versions. We will not be held liable for any damage
  137.    to or loss of data arising from the use of this program.
  138.  
  139. 6: The file 'OLESpec', inside the !OLEedit application directory is not part
  140.    of the application and is included for information only (and may be
  141.    omitted when OLE Edit is included in a commercial application). Copyright
  142.    of this file remains with Computer Concepts Ltd. I'm not sure exactly what
  143.    those rights are, but it seems to be pretty free & easy (it's the module
  144.    they don't want thrown around - which is why this program was written in
  145.    the first place). If there's any objection I'll remove it from future
  146.    uploads.
  147.  
  148. Peter Greenham
  149.  
  150. Queries, plaudits and brickbats (and some constructive comments as well
  151. please) to:
  152.  
  153. email: PGreenham@arcade.demon.co.uk
  154.        User #963 at Arcade BBS (081-654-2212)
  155.  
  156. snail: Peter Greenham
  157.        1 Dawn Gardens
  158.        Sleeper's Hill
  159.        Winchester
  160.        Hants
  161.        SO22 4NS
  162.  
  163. Version 1.00 (30-Jun-1994)
  164. - First distributed version.
  165. Very basic feasibility study, more interested in OLEing than actual editing.
  166.  
  167. Version 1.01 (30 Jun 1994)
  168. - First bug fix (already!)
  169. Program crashed when sent an empty file. Can you believe I'd only tested
  170. editing files with stuff in them?
  171.  
  172. Version 2.00 (14 Jul 1994)
  173. - Major version increment as it's been completely rewritten using RiscOSLib
  174. - Full text editor, just like Edit. Including Import/Export
  175. - Pane along the bottom with OK/Cancel. Any ideas on better verbs?
  176.  
  177. Negative changes:
  178. Although RiscOSLib has a text editor, it is more troublesome than I'm used to
  179. for certain other things:
  180.  
  181. - No Messages file.
  182. - No Close icon. I can't get it to behave as RiscOSLib txt/txtedit libraries
  183.   do strange undocumented things on close which I can't stop.
  184. - I also can't seem to control the titlebar properly. If you save the
  185.   textfile via the save box, the new path will be put into the titlebar.
  186.   Don't worry though, it will still send it back to the client properly.
  187. - Pane handling not quite right. Toggle to full-size and you'll see what I
  188.   mean.
  189. - Takes up more memory.
  190.  
  191. Version 2.01 (16 Jul 1994)
  192. - Bug fix: On reopen when window is already open, will now properly reopen
  193.   main text window.
  194.  
  195. - Change: On reopen, will place caret at its last position, not at beginning.
  196.  
  197. - Hide button added on the pane. Hides the window.
  198.  
  199. - Rather serious bug fixed: Beforehand, once running it would intercept a
  200.   request to edit ANY filetype. Now will only respond when filetype in
  201.   OLEOpenSession block is Text (&FFF). Note this is independant of the file
  202.   type of the actual file saved to the swap location, which OLE Edit will
  203.   display correctly.
  204.  
  205. - Extremely serious bug fixed where the text files were only being partially
  206.   saved.
  207.  
  208.   Unbelievably, RiscOSLib doesn't have a txt_save() function, which
  209.   considering the preponderence of useless functions and the fact that the
  210.   text isn't held as a contiguous block is by my books pretty damn
  211.   uncivilised. Anyway, if you ever have to use txt or txtedit (which this
  212.   application should preclude) you might be interested in these:
  213.  
  214. static void txt_write(txt t, FILE* stream)
  215. {
  216.     int pos;
  217.     int size;
  218.     
  219.     size = txt_size(t);
  220.     pos = 0;
  221.     
  222.     while (pos < size)
  223.     {
  224.         int blocksize;
  225.         char* data;
  226.         
  227.         txt_arrayseg(t, pos, &data, &blocksize);
  228.         fwrite(data, blocksize, 1, stream);
  229.         pos += blocksize;
  230.     }
  231. }
  232.  
  233.  
  234. static BOOL txt_save(txt t, char* pathname)
  235. {
  236.     FILE* fh;
  237.     
  238.     fh = fopen(pathname, "wb");
  239.     if (!fh)
  240.     {
  241.         return (FALSE);
  242.     }
  243.     
  244.     txt_write(t, fh);
  245.     
  246.     fclose(fh);
  247.     
  248.     return (TRUE);
  249. }
  250.  
  251.  
  252.  
  253.  
  254. Future plans:
  255.  
  256. Do our own menu which is more Style Guide compliant. More sensible too:
  257. Export for instance rather than Save. Instead of the Display menu, a Choices
  258. window allowing interactive setup of OLEEdit$Options. as well as other
  259. options.
  260.  
  261. In fact, get the **** off RiscOSLib. OK, it has a text editor, but it's not
  262. what I'd charitably call a civilised library. Aargh!
  263.